package PTA_05_29;
//定义四个类，分别为Employee类、SalariedEmployee类、HourlyEmployee类和CommissionEmployee类。
// 其中Employee类是其他三个类的父类。Employee类包含姓名和身份证号。
// 除此之外，SalariedEmployee类还应包含每月工资；
// HourlyEmployee类还应包含每小时工资数和工作时间数；
//CommissionEmployee还应包含提成比例和销售总额。
// 其中HourlyEmployee的工资为：每小时工资数×工作时间数，
// CommissionEmployee的工资为：提成比例×销售总额。
// 每个类都应有合适的构造方法、数据成员的设置和读取方法。
// 编写一个测试程序，创建这些类的对象，并输出与对象相关的信息。
// 注意子类有时需调用父类的构造方法和被覆盖的方法，成员变量定义为private，对有些方法实现重载。

import java.util.Scanner;

abstract class Employee
{
    private String name;
    private String ID;

    public Employee(String name, String ID) {
        this.name = name;
        this.ID = ID;
    }

    public Employee() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getID() {
        return ID;
    }

    public void setID(String ID) {
        this.ID = ID;
    }
    abstract double getSalary();

    @Override
    public String toString() {
        return '[' + "name=" + name  + ",id=" + ID  + ']';
    }
}
class HourlyEmployee extends Employee
{
    private double hourSalary;
    private double hours;

    public HourlyEmployee(String name, String ID, double hourSalary, double hours) {
        super(name, ID);
        this.hourSalary = hourSalary;
        this.hours = hours;
    }

    public HourlyEmployee() {
    }

    public double getHourSalary() {
        return hourSalary;
    }

    public void setHourSalary(double hourSalary) {
        this.hourSalary = hourSalary;
    }

    public double getHours() {
        return hours;
    }

    public void setHours(double hours) {
        this.hours = hours;
    }

    @Override
    double getSalary() {
        return getHourSalary() * getHours();
    }

    @Override
    public String toString() {
        return  "HourlyEmployee" + super.toString() +
                "[hourSalary=" + hourSalary +
                ",workhour=" + hours +
                ']';
    }
}
class SalariedEmployee extends Employee
{
    private double monSalary;

    public SalariedEmployee(String name, String ID, double monSalary) {
        super(name, ID);
        this.monSalary = monSalary;
    }

    public SalariedEmployee() {
    }

    public double getMonSalary() {
        return monSalary;
    }

    public void setMonSalary(double monSalary) {
        this.monSalary = monSalary;
    }

    @Override
    double getSalary() {
        return getMonSalary();
    }

    @Override
    public String toString() {
        return "SalariedEmployee" + super.toString() +
                "[monthSalary=" + monSalary +']';
    }
}
class CommissionEmployee extends Employee
{
    private double ration;
    private double volume;

    public CommissionEmployee(String name, String ID, double ration, double volume) {
        super(name, ID);
        this.ration = ration;
        this.volume = volume;
    }

    public CommissionEmployee() {
    }

    public double getRation() {
        return ration;
    }

    public void setRation(double ration) {
        this.ration = ration;
    }

    public double getVolume() {
        return volume;
    }

    public void setVolume(double volume) {
        this.volume = volume;
    }

    @Override
    double getSalary() {
        return getRation() * getVolume();
    }

    @Override
    public String toString() {
        return "CommissionEmployee" + super.toString() +
                "[commissionRatio=" + ration +
                ",sale=" + volume +
                ']';
    }
}

public class Main4 {
    public static void main(String [] args){
        Scanner in=new Scanner(System.in);
        Employee [] e=new Employee[3];
        e[0]=new SalariedEmployee(in.next(),in.next(),in.nextDouble());
        e[1]=new HourlyEmployee(in.next(),in.next(),in.nextDouble(),in.nextDouble());
        e[2]=new CommissionEmployee(in.next(),in.next(),in.nextDouble(),in.nextDouble());
        for(int i=0;i<e.length;i++)
        {
            System.out.println(e[i].getSalary());
            System.out.println(e[i]);
        }
    }
}
